package eerbaar.v2.app.mover;

import eerbaar.message.lib.NotifyPetMove;
import eerbaar.shared.message.IMessageReader;
import eerbaar.shared.message.Message;
import eerbaar.shared.message.MsgHelper;

public class PetWatcher implements IMessageReader {

    private final IPersonaMover mover;
    private final String program;

    public PetWatcher(IPersonaMover mover, String program) {
        this.mover = mover;
        this.program = program;

        MsgHelper.registerReader(NotifyPetMove.class, this);
    }

    @Override
    public boolean read(Message msg) {

        this.mover.runProgram(this.program);

        MsgHelper.unregisterReader(NotifyPetMove.class, this);
        return false;
    }

}
